package com.yadang.infra.controller;

import com.yadang.infra.base.ApiResult;
import com.yadang.infra.bean.CmmDictType;
import com.yadang.infra.service.CmmDictTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.lang.invoke.MethodHandles;
import java.util.List;

@Api(tags = "字典类型表接口")
@RestController
@RequestMapping("/infra/cmmDictType")
public class CmmDictTypeController {
    private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

    @Autowired
    private CmmDictTypeService cmmDictTypeService;

    @ApiOperation("插入一条字典类型数据")
    @PostMapping("insertDictType")
    public ApiResult<?> insertDictType(String type, String desc) {
        cmmDictTypeService.insertDictType(type, desc);
        return ApiResult.success();
    }

    @ApiOperation("查询所有字典类型")
    @PostMapping("selectAllType")
    public ApiResult<?> selectAllType() {
        List<CmmDictType> cmmDictTypeList = cmmDictTypeService.selectAllType();
        return ApiResult.success(cmmDictTypeList);
    }

}
